package com.liang.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liang.entity.CNotice;
import com.liang.entity.CUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 李昂
 * @since 2020-11-30
 */
public interface CUserMapper extends BaseMapper<CUser> {

    /**
     * @Author 李昂
     * @Description 获取全部用户
     * @Date 2020/12/3 18:36
     */
    //@Select("select * from c_user inner join c_user_detail on c_user.id = c_user_detail.id")
    List<CUser> allUsers();

    /**
     * @Author 李昂
     * @Description 获取个人全部信息
     * @Date 2020/12/7 15:08
     */
    CUser getIUserBySon(@Param("sno") String sno);

    //修改用户状态
    boolean ChangeStatueById(@Param("id") String id, @Param("statue") String statue);

    //初始用户密码
    @Update("update c_user set password = #{pwd} where id = #{id}")
    boolean ChushiPwd(@Param("id") String id, @Param("pwd") String pwd);

    //修改用户权限
    @Update("update c_user set role = #{role} where id = #{id}")
    boolean ChangeRole(@Param("id") String id, @Param("role") String role);

    //远程搜索用户名
    List<CUser> getWeiji(@Param("name") String name);

    //获取优秀社员的信息
    List<CUser> getExcellentUser();

    //加载后台桌面数据
    @Select("select  count(*) newscount , (select count(*) from c_blog) blogcount,(select count(*) from c_active) activecount,notice.time  ,notice.container  from c_news ,(select * from c_notice n where nid = (select max(nid) from c_notice)) notice")
    CNotice getNotice();


}
